<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>CSS3代码书写小三角</title>
  <style>
    div {
      position: relative;
      width: 249px;
      height: 35px;
      border: 1px solid #000;
    }

    div::after {
      content: "";
      position: absolute;
      top: 8px;
      right: 15px;
      width: 8px;
      height: 8px;
      border-right: 1px solid #000;
      border-bottom: 1px solid #000;
      
      /* 旋转45度 */
      transform: rotate(45deg);
      
      /* 过渡动画 */
      transition: all 0.3s;
    }

    div:hover::after {
      top: 12px;
      transform: rotate(225deg);
    }
  </style>
</head>
<body>

  <div></div>
  
</body>
</html>